
import ToastModel from "./ToastModel";
import ItemToastModel from "./ItemToastModel";
import BaseController from "../base/controller/BaseController";
import GameManager from "../game/GameManager";

export default class ToastController extends BaseController {

    private static ins: ToastController;

    static instance() {
        if (!this.ins) {
            this.ins = new ToastController();
        }
        return this.ins;
    }

    intoLayer(langID: string, opt?) {
        let content = GameManager.instance().getLocalString(langID, opt);
        this.pushView('prefabs/battle/ToastView', new ToastModel(content));
    }

    show(content: string, image?: string,node?:cc.Node,func?:Function) {
        if (image) {
            this.pushView('prefabs/battle/ItemToastView', new ItemToastModel(content, image),node,func);
        } else {
            this.pushView('prefabs/battle/ToastView', new ToastModel(content),node,func);
        }
    }

}
